package cc.co.bengkeljava.codex.designpattern.observer.ex1;

public class Main {
	public static void main(String[] args) {
		Publisher newspaperX = new Newspaper("Newspaper X");
		Publisher newspaperY = new Newspaper("Newspaper Y");

		Subscriber bapa = new SubscriberImpl("Bapa");
		Subscriber pakKosim = new SubscriberImpl("Pak Kosim");
		Subscriber pakIndra = new SubscriberImpl("Pak Indra");

		newspaperX.notifySubcriber();
		newspaperY.notifySubcriber();

		newspaperX.subscribe(bapa);
		newspaperY.subscribe(bapa);

		newspaperX.notifySubcriber();
		newspaperY.notifySubcriber();

		newspaperX.subscribe(pakKosim);
		newspaperY.subscribe(pakKosim);
		newspaperX.subscribe(pakIndra);
		newspaperY.subscribe(pakIndra);

		newspaperX.notifySubcriber();
		newspaperY.notifySubcriber();

		newspaperX.stopToSubscribe(pakIndra);
		newspaperY.stopToSubscribe(pakIndra);

		newspaperX.notifySubcriber();
		newspaperY.notifySubcriber();
	}
}
